<%@ page language="java" contentType="text/html; charset=UTF-8"%>

<!DOCTYPE html>
<html>
	<head>
		<title>商城后台_分类管理</title>
		<%@include file="../header.jsp" %>
		<style>
			body{padding-top: 70px;}
			._category{width: 50px;height: 25px;border: 1px solid #DDDDDD;border-radius: 5px;text-align: center;line-height: 25px;}
			._category_add{width: 100px;height: 25px;line-height: 25px;margin-top: 3px;}
			
			._addgood{background-color: white;border: 1px solid #cccccc;border-radius: 3px;height: 28px;}
			
			/*a  upload */
			.a-upload {padding: 4px 10px;height: 20px;line-height: 20px;position: relative;cursor: pointer;color: #888;background: #fafafa;border: 1px solid #ddd;border-radius: 4px; overflow: hidden;display: inline-block;*display: inline;*zoom: 1}
			.a-upload  input {position: absolute;font-size: 100px;right: 0;top: 0;opacity: 0;filter: alpha(opacity=0);cursor: pointer}
			.a-upload:hover {color: #444;background: #eee;border-color: #ccc;text-decoration: none}
		</style>
	</head>
	<body>
		<%@include file="top.jsp" %>
		
		<div class="container">
			<form class="well" action="admin_addGood.action" method="POST" enctype="multipart/form-data">
				<div class="row">
					<div class="span4">
						<s:textfield name="good.name" placeholder="这里输入商品名称"></s:textfield>
					</div>
					<div class="span4">
						<s:textfield name="good.price" placeholder="这里输入商品价钱"></s:textfield>
					</div>
				</div>
				
				<div class="row">
					<div class="span4">
						<s:textfield name="good.description" placeholder="这里输入商品描述" cssClass="span4"></s:textfield>
					</div>
					<div class="span4">
						<s:textfield name="good.place" placeholder="这里输入商品产地" ></s:textfield>
					</div>
				</div>
				
				<div class="row">
					<div class="span4">
						<a href="javascript:;" class="a-upload">
						    <input type="file" name="goodImg" >点击这里上传商品图片文件(png,jpg,bmp类型)
						</a>
					</div>
				</div>
				
				<div class="row">
					<div class="span4">
						<select id="_pcategory" onchange="doshowcategory()">
							<option>==请选择一级分类==</option>
							<option value="clothes01">衣服</option>
							<option value="digital01">数码</option>
							<option value="shoes01">鞋子</option>
						</select>
					</div>
					<div class="span4">
						<select id="_category" name="category.id" onchange="doshowgood()" >
							<option>==请选择二级分类==</option>
						</select>
					</div>
					<div class="span3">
						<button class="_addgood" onclick="doSubmit()">商品上架</button>
					</div>
				</div>
				
				
			</form>
		</div>
			
		
		<script>
			$('.dropdown-toggle').dropdown();

			//异步获取二级分类
			function doshowcategory(){
				var pc = $('#_pcategory option:selected').val();
				if(pc != '==请选择一级分类=='){
					$.ajax({
						url:"${basePath}admin_ajaxgetCategory.action",
						data:{"pcategory.id":pc},
						type:"POST",
						dataType:"json",
						success:function(data){
							var c = $('#_category');
							c.empty();
							c.append('<option>==请选择二级分类==</option>');
							for(var i = 0; i<data.categorylist.length;i++){
								c.append('<option value="'+data.categorylist[i].id+'" >'+data.categorylist[i].name+'</option>');
							}
						},
						error: function(){alert("false");
						}
					});
				}else{
					var c = $('#_category');
					c.empty();
					c.append('<option>==请选择二级分类==</option>');
				}
			}

			function doSubmit(){
				document.forms[0].submit();
			}
			
		</script>
	</body>
</html>
